<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of promos_,model
 *
 * @author daw
 */
class Promoscines_model extends CI_Model {

    public function __construct() {
        $this->load->database();
    }

    public function insert($arr_insert) {
        $this->db->insert('promociones_pelicula', $arr_insert);
    }

    public function get_promos($slug = FALSE) {
        if ($slug === FALSE) {
            $query = $this->db->get('promociones_sala');
            //Returnarray devuelve toods los resultados
       
            $aux = $query->result_array();

            for ($i = 0; $i < count($aux); $i++) {
                $aux[$i]['cod_sala'] = $this->get_nombre($aux[$i]['cod_sala']);
            }
            return $aux;
        }

        $query = $this->db->get_where('promociones_sala', array('cod_promociones' => $slug));
        return $query->row_array();
    }

    public function get_promos_sala($slug = FALSE) {
        if ($slug === FALSE) {
            $query = $this->db->get('promociones_sala');
            //Returnarray devuelve toods los resultados
            return $query->result_array();
        }

        $query = $this->db->get_where('promociones_sala', array('cod_sala' => $slug));
        return $query->row_array();
    }

    public function get_nombre($aux ) {

        $resultado = $query = $this->db->get_where('salas', array('cod_salas' => $aux));


        $data = $resultado->row_array();

        return $data['nombre'];
    }

}
